<template>
	<view>
		<view class="mar-15 tform">
			<view class="between center tform-item hang-no">
				<view class="value flex">功能名称</view>
				<view>
					<u-input v-model="form.name" input-align="right" placeholder="请输入功能名称" />
				</view>
			</view>
			<view class="between center tform-item hang-no">
				<view class="value flex">功能编码</view>
				<view>
					<u-input v-model="form.code" input-align="right" placeholder="请输入功能编码" />
				</view>
			</view>
			<view class="between center tform-item hang-no">
				<view class="value flex">排序编号</view>
				<view>
					<u-input v-model="form.sort" input-align="right" placeholder="请输入排序编号" />
				</view>
			</view>
			<view class="between center tform-item hang-no">
				<view class="value flex">定时器秒</view>
				<view>
					<u-input v-model="form.second" input-align="right" placeholder="请输入查询多少秒之前数据" />
				</view>
			</view>
			<view class="between center">
				<view class="value flex">功能描述</view>
				<view class="flex-1">
					<u--textarea v-model="form.describe" height="200" maxlength="-1" placeholder="请输入内容"></u--textarea>
				</view>
			</view>
			<view class="between center">
				<view class="value flex">功能补充</view>
				<view class="flex-1 mar-5-0">
					<u--textarea v-model="form.remark" height="100" maxlength="-1" placeholder="请输入功能补充"></u--textarea>
				</view>
			</view>
		</view>
		<view class="center">
			<u-button class="btn" type="primary" @click="confirmBtn">提交</u-button>
		</view>
	</view>
</template>

<script>
	import {
		dictionaryAdd,
		dictionaryEdit,
		dictionaryDelete,
		dictionaryStatus
	} from '../../api/dictionary'
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	export default {
		props: {
			item: Object
		},
		data() {
			return {
				form: {},
			}
		},
		mounted() {
			if (this.item) {
				this.form = this.item
			}

		},
		methods: {
			confirmBtn() {
				if (!this.form.name) {
					this.$u.toast('请填写功能名称')
					return;
				}
				if (!this.form.code) {
					this.$u.toast('请填写功能编码')
					return;
				}

				if (this.form.id) {
					dictionaryEdit(this.form).then(res => {
						uni.$emit('handleClose')
					})
				} else {
					dictionaryAdd(this.form).then(res => {
						uni.$emit('handleClose')
					})
				}
			}
		}
	}
</script>

<style scoped>
	uni-input {
		text-align: right;
	}

	.img {
		width: 80px;
		height: 80px;
	}
</style>